<%--
  Created by IntelliJ IDEA.
  User: yangtao
  Date: 2021-09-07
  Time: 11:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<div class="app-title">
    <div>
        <h1><i class="fa fa-th-list"></i>井控案例查询</h1>
    </div>
</div>
<div class="row">
    <div class="clearix"></div>
    <div class="col-md-12">
        <div class="tile">
            <h3 class="tile-title">精准查询</h3>
            <div class="tile-body">
                <form class="row">
                    <div class="input-group col-md-3">
                        <label class="control-label">井号</label>
                        <input type="text" class="form-control" id="wellnum">
                    </div>
                    <div class="form-group col-md-3">
                        <label class="control-label">区块名称</label>
                        <input class="form-control" type="text" id="area">
                    </div>
                    <div class="form-group col-md-3">
                        <label class="control-label">所属单位</label>
                        <input class="form-control" type="text" id="proprietor">
                    </div>
                    <div class="form-group col-md-3" hidden>
                        <label class="control-label">所属单位</label>
                        <input class="form-control" type="text" id="backValue">
                    </div>
                    <div class="form-group col-md-3 align-self-end">
                        <button class="btn btn-primary" type="button" onclick="getInfos()"><i
                                class="fa fa-fw fa-lg fa-search"></i>查询
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="col-md-12">
        <div class="tile">
            <h3 class="tile-title">模糊查询</h3>
            <div class="tile-body">
                <div class="form-group" style="width: 70%; margin: 0 auto;">
                    <textarea class="form-control" id="searchWords" rows="4"></textarea>
                </div>
                <div class="form-group" style="width: 80px; margin: 10px auto;">
                    <button class="btn btn-primary" type="button"
                            onclick="matchQuery()"><i class="fa fa-fw fa-lg fa-search"></i>查询
                    </button>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-12" id="casesearchlist"></div>
</div>
<script type="text/javascript">
    function getInfos() {
        $.post("${ctx}/well/searchwellinfo/" + $("#wellnum").val() +
            "/" + $("#area").val() + "/" + $("#proprietor").val(), function (result) {
            $("#casesearchlist").html(result);
        });
    }
    function matchQuery() {
        var searchWords = $("#searchWords").val();
        $.post("${ctx}/es/match", {
            searchString: searchWords,
            from: 0
        }, function (data, status) {
            alert(status);
            if (status == 404) {
                swal({
                    title: "查询结果",
                    text: "没有与:\"" + searchWords + "\"相关的井控案例！",
                    html: true,
                    type: "warning",
                    showCancelButton: false,
                    confirmButtonText: "确认",
                    closeOnConfirm: false
                });
            } else {
                $("#casesearchlist").html(data);
            }
        }).errorCallback(function (status) {
            alert(status);
        });
    }/.
</script>